package com.example.designpatterns.composite;

/**
 * 测试
 */
public class Test {
    public static void main(String[] args) {
        //定义根目录
        FileComponent rootComponent = new FileFolder("我是根目录", 1, 1);
        //定义二级文件夹
        FileComponent secondLevelComponent = new FileFolder("我是二级目录", 2, 1);
        //定义文件
        FileComponent file = new FileItem("我是文件", 3, 2);
        //向根目录添加二级目录
        rootComponent.add(secondLevelComponent);
        //向二级目录添加文件
        secondLevelComponent.add(file);
        //打印
        rootComponent.print();
    }
}
